//
//  UIView+YSAdd.h
//  YSKitExample
//
//  Created by Kyson on 2017/6/16.
//  Copyright © 2017年 YangShen. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>

@interface UIView (YSAdd)

/**
 *  通过XIB快速创建View
 */
+ (nullable instancetype)ys_viewFromXib;

/**
 *  增加圆角效果
 *
 *  @param corner    圆角位置
 *  @param radioSize 圆角半径
 */
- (void)ys_makeRoundCorner:(UIRectCorner)corner radio:(CGSize)radioSize;

/*
 ** lineFrame:     虚线的 frame
 ** length:        虚线中短线的宽度
 ** spacing:       虚线中短线之间的间距
 ** color:         虚线中短线的颜色
 */
+ (nullable UIView *)ys_createDashedLineWithFrame:(CGRect)lineFrame
                                       lineLength:(int)length
                                      lineSpacing:(int)spacing
                                        lineColor:(nullable UIColor *)color;

/**
 * 截屏
 */
- (nullable UIImage *)ys_snapshotImage;

/**
 * 截屏，快，但是可能会导致屏幕刷新
 */
- (nullable UIImage *)ys_snapshotImageAfterScreenUpdates:(BOOL)afterUpdates;

/**
 Create a snapshot PDF of the complete view hierarchy.
 */
- (nullable NSData *)ys_snapshotPDF;

/**
 *  设置阴影
 *
 *  @param color  阴影颜色
 *  @param offset 阴影偏移
 *  @param radius 阴影半径(模糊程度)
 */
- (void)ys_setLayerShadow:(nullable UIColor *)color offset:(CGSize)offset radius:(CGFloat)radius;

#pragma mark -
/**
 *  寻找第一响应者
 */
- (nullable UIView *)ys_findFirstResponder;

/**
 *  当前窗口是否显示
 */
- (BOOL)ys_isShowingOnKeyWindow;

/**
 *  删除所有子试图
 */
- (void)ys_removeAllSubviews;

/**
 * 返回视图的控制器
 */
@property (nullable, nonatomic, readonly) UIViewController *ys_viewController;

#pragma mark - property
@property (nonatomic) CGFloat ys_x;         ///< frame.origin.x
@property (nonatomic) CGFloat ys_y;         ///< frame.origin.y
@property (nonatomic) CGFloat ys_right;     ///< frame.origin.x + frame.size.width
@property (nonatomic) CGFloat ys_bottom;    ///< frame.origin.x + frame.size.height
@property (nonatomic) CGFloat ys_width;     ///< frame.size.width
@property (nonatomic) CGFloat ys_height;    ///< frame.size.height
@property (nonatomic) CGFloat ys_centerX;   ///< center.x
@property (nonatomic) CGFloat ys_centerY;   ///< center.y
@property (nonatomic) CGPoint ys_origin;    ///< frame.origin
@property (nonatomic) CGSize  ys_size;       ///< frame.size

@end
